<%-- 
    Document   : Profile
    Created on : Nov 2, 2011, 12:02:27 AM
    Author     : MrKoi
--%>

<%@page import="DAL.CustomerBean"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page session="true" import="java.util.Collection" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>East2West Tours and Travels</title>
        <script src="js/gen_validatorv4.js" type="text/javascript"></script>
        <style type="text/css">
            #khun
            {
                margin-left:auto;
                margin-right:auto;
                width:490px;                
                background-color:#f7f6f6;                
            }
            #username
            {
                font-family:"Times New Roman", Times, serif;
                font-size:large;
                font-weight:bold;
                width:200px;
                
            }
            #profile
            {
                font-family:"Times New Roman", Times, serif;
                color:black;
                font-size:large;
                font-weight:bold;
                 color:#0707e7;
            }
            .font
                {                
                font-size:14px;
                font-weight:bold;
                width:200px;                
                margin-left:5px;                 
                }
        </style>         
    </head>
    <body>
    <%
        String username="";
        if(session.getAttribute("User").toString()!=null)
            {
                username=session.getAttribute("User").toString();
                CustomerBean cusbean=new CustomerBean();
                Collection kp=cusbean.SelectProfile(username);
                request.setAttribute("ct",kp);
            }
    %> 
    <center>
                <span style="font-size: 20px;color: #343434;">Profile</span></center>  
    <div id="khun">
        <form action="ControllerProfile" method="post" id="commentForm"> 
         <table border="0" cellpadding="1" cellspacing="1" width="490px">
            <tr>
                <td colspan="3"><div class="font">Customer Information</div></td>
            </tr>
            <tr>
                <td width="120px"></td>
                <td width="120px"></td>
                <td></td>
            </tr>
            <tr>
                <td align="right">UserName:</td>
                <td><div id="username"><%=username%></div></td>
                <td></td>
            </tr>  
            <tr><td colspan="3"><hr></td></tr>
            <c:forEach items="${ct}" var="cubean">    
            <tr>
                <td colspan="2"><div class="font">Personal Information</div></td>
                <td></td>
            </tr>
            <tr>
                <td>Full Name</td>
                <td style="color:red;"><input type="text"  name="fullname" value="${cubean.fullName}" maxlength="30" size="30"/></td>
                <td style="color:red;"><div id='commentForm_fullname_errorloc' class="error_strings"></div></td>
            </tr>
            <tr>
                <td>Gender:</td>
                <td>
                    <c:if test="${cubean.gender=='Male'}" >
                        <input type="radio" name="gender" value="Male" checked="True" />Male
                        <input type="radio" name="gender" value="Female" />Female
                    </c:if>
                    <c:if test="${cubean.gender=='Female'}" >
                        <input type="radio" name="gender" value="Male"/>Male
                        <input type="radio" name="gender" value="Female" checked="True"/>Female
                    </c:if>
                </td>
            </tr>
            <tr>
                <td>Email:</td>
                <td style="color:red;"><input type="text" name="email" value="${cubean.email}" maxlength="30" size="30"/></td>
                <td style="color:red;"><div id='commentForm_email_errorloc' class="error_strings"></div></td>
            </tr>
            <tr>
                <td>Country:</td>
                <td>
                    <select name="country" id="country">
                      <c:if test="${cubean.country=='Viet Nam'}">
                        <option value="Viet Nam" selected>Viet Nam</option>
                      </c:if>
                      <c:if test="${cubean.country=='Lao'}">
                         <option value="Lao" selected>Lao</option>
                      </c:if>
                      <c:if test="${cubean.country=='CamPuchia'}">
                        <option value="CamPuchia" selected>CamPuchia</option>
                      </c:if>
                      <c:if test="${cubean.country=='Thai Lan'}">
                        <option value="Thai Lan" selected>Thai Lan</option>
                      </c:if>
                      <c:if test="${cubean.country=='Indonesia'}">
                        <option value="Indonesia" selected>Indonesia</option>
                      </c:if>
                      <c:if test="${cubean.country=='Singapore'}">
                        <option value="Singapore" selected>Singapore</option>
                      </c:if>
                      <c:if test="${cubean.country=='Japan'}">
                        <option value="Japan" selected>Japan</option>
                      </c:if>
                      <c:if test="${cubean.country=='Russia'}">
                        <option value="Russia" selected>Russia</option>
                      </c:if>
                      <c:if test="${cubean.country=='Korea'}">
                        <option value="Korea" selected>Korea</option>
                      </c:if>
                      <c:if test="${cubean.country=='England'}">
                        <option value="England" selected>England</option>
                      </c:if>
                      <c:if test="${cubean.country=='France'}">
                        <option value="France" selected>France</option>
                      </c:if>
                      <c:if test="${cubean.country=='Australia'}">
                        <option value="Australia" selected>Australia</option>
                      </c:if>
                      <c:if test="${cubean.country=='United States'}">
                        <option value="United States" selected>United States</option>
                      </c:if>
                      <option value="Viet Nam">Viet Nam</option>
                      <option value="Lao">Lao</option>
                      <option value="CamPuchia">CamPuchia</option>
                      <option value="Thai Lan">Thai Lan</option>
                      <option value="Indonesia">Indonesia</option>
                      <option value="Singapore">Singapore</option>
                      <option value="Japan">Japan</option>
                      <option value="Russia">Russia</option>
                      <option value="Korea">Korea</option>
                      <option value="England">England</option>
                      <option value="France">France</option>
                      <option value="Australia">Australia</ption>
                      <option value="United States">United States</option>
                     </select>
                </td>
            </tr>
            <tr>
                <td>Address</td>
                <td style="color:red;"><textarea rows="3" cols="25" name="address"  size="30">${cubean.address}</textarea></td>
                <td style="color:red;"><div id='commentForm_address_errorloc' class="error_strings"></div></td>
            </tr>
            <tr>
                <td>Phone</td>
                <td style="color:red;"><input type="text" name="phone" value="${cubean.phone}" maxlength="13" size="30"/></td>
                <td style="color:red;"><div id='commentForm_phone_errorloc' class="error_strings"></div></td>
            </tr>
         </c:forEach>  
             <tr>
                 <td></td>
                 <td><input type="hidden" name="user" value="<%=username%>" /></td>
                 <td></td>
             </tr>
             <tr>
                <td></td>
                <td><input type="submit" name="update" value="Update Information" /></td>
                <td></td>
            </tr>
            <tr><td colspan="3"><hr></td></tr>   
        </table>
        </form>
        
        <script language="JavaScript" type="text/javascript">
            var frmvalidator  = new Validator("commentForm");
            frmvalidator.EnableOnPageErrorDisplay();
            frmvalidator.EnableMsgsTogether();
                                           
            frmvalidator.addValidation("fullname","req","*");
            frmvalidator.addValidation("fullname","minlength=8", "Full name at least 8 characters");
            
            frmvalidator.addValidation("email","req","*");
            frmvalidator.addValidation("email","email","Please enter a valid email address");
            
            frmvalidator.addValidation("address","req","*");
            frmvalidator.addValidation("address","minlength=15", "Address at least 15 characters");
            
            frmvalidator.addValidation("phone","req","*");
            frmvalidator.addValidation("phone","minlength=10","Phone number at least 10 digits");
            frmvalidator.addValidation("phone","numeric","Please enter only digits");
        </script>
        
        <form action="ControllerProfile" method="post" id="formpass" name="formpass">
            <table>
                           
            <tr>
                <td colspan="2" align="left"><div class="font">Change Password</div></td>
            </tr>
            <tr>
                 <td></td>
                 <td><input type="hidden" name="user" value="<%=username%>" /></td>
             </tr>
            <tr>
                <td>PassWord Old:</td>
                <td style="color:red;"><input type="password" name="passOld" maxlength="15" size="30"/></td>
                <td style="color:red;"><div id='formpass_passOld_errorloc' class="error_strings"></div></td>
            </tr>
            <tr>
                <td>PassWord New:</td>
                <td style="color:red;"><input type="password" id="passNew" name="passNew" maxlength="15" size="30"/></td>
                <td style="color:red;"><div id='formpass_passNew_errorloc' class="error_strings"></div></td>
            </tr>
            <tr>
                <td>Confirm Password:</td>
                <td style="color:red;"><input type="password" id="confirm_password" name="confirm_password" maxlength="15" size="30"/></td>
                <td style="color:red;"><div id='formpass_confirm_password_errorloc' class="error_strings"></div></td>
            </tr>   
            <tr>
                <td></td>
                <td><input type="submit" name="update" value="Change Password" /></td>
            </tr>
            </table>
        </form> 
        <script language="JavaScript" type="text/javascript">
        var frmvalidator1  = new Validator("formpass");
            frmvalidator1.EnableOnPageErrorDisplay();
            frmvalidator1.EnableMsgsTogether();            
            
            frmvalidator1.addValidation("passOld","req","*");
            frmvalidator1.addValidation("passOld","minlength=8", "Password at least 8 characters");
            
            frmvalidator1.addValidation("passNew","req","*");
            frmvalidator1.addValidation("passNew","minlength=8", "Password at least 8 characters");
            
            frmvalidator1.addValidation("confirm_password","req","*");
            frmvalidator1.addValidation("confirm_password","eqelmnt=passNew", "Please enter the same password as above");
    </script>
    </div>
   
    </body>
</html>
